-- hp_to_attack
-- created by chendh
-- 生命高于一定百分比时提升攻击

return {
    -- 返回的是提升的攻击点数
    apply = function(prop, baseValue)
        return prop[3];
    end,

    trigger = function(who, prop, attack)
        local rate = math.modf(1000 * who:queryAttrib("hp") / who:queryAttrib("max_hp"));

        -- 提升加成
        local value = prop[3];
        local specialProp = PropM.combine(who, "prop_force_add", prop[1]);
        if specialProp[3] > 0 then
            value = PropM.apply(specialProp, value);
        end

        if (rate >= tonumber(prop[2])) then
            return math.floor(attack * value / 1000);
        end

        return 0;
    end,

    record = function(target, prop, path)
        return false;
    end
};
